package com.hmall.api.client;

import com.hmall.api.domain.dto.ItemDTO;
import com.hmall.api.domain.dto.OrderDetailDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

@FeignClient("item-service")// 负载均衡服务器地址，Feign客户端
public interface ItemClient {
    /**
     * 根据id批量查询商品
     * @param ids
     * @return
     */
    // 声明新的接口，用于调用负载均衡服务器
    @GetMapping("items")
    List<ItemDTO> queryItemByIds(@RequestParam("ids")Collection<Long> ids);

    /**
     * 批量扣减库存
     * @param items
     */
    @PutMapping("/items/stock/deduct")
    public void deductStock(@RequestBody List<OrderDetailDTO> items);
}
